using CosyTrade.Core;
using CosyTrade.Network;

namespace CosyTrade.UI
{
    public class Operation : IOperation
    {
        public static  Operation Instance ;
        private static IRemotingPortalFactory proxy;

        public static void CreateInstance()
        {
            Instance = new Operation();
        }

        private Operation()
        {
            proxy = (IRemotingPortalFactory) AddinServices.Instance.AddinManager.GetAddin("RemotingProxyManager");
            proxy.RegisterProxy<IClientRelationManager>("ClientRelationManager");
            proxy.RegisterProxy<IDistrbutionSystem>("DistrbutionSystem");
            proxy.RegisterProxy<IFinancialSystem>("FinancialSystem");
            proxy.RegisterProxy<IOrganizationSystem>("OrganizationSystem");
            proxy.RegisterProxy<IProductManager>("ProductManager");
            proxy.RegisterProxy<ISecuritySystem>("SecuritySystem");
            proxy.RegisterProxy<IStoreManager>("StoreManager");
            proxy.RegisterProxy<ITradeSystem>("TradeSystem");
            proxy.RegisterProxy<IDataStorage>("DataStorage");
            proxy.RegisterProxy<IFuturesManager>("FuturesOrderManager");
        }

        public IClientRelationManager ClientRelationManager
        {
            get { return proxy.GetProxy<IClientRelationManager>(); }
        }

        public IDistrbutionSystem DistrbutionSystem
        {
            get { return proxy.GetProxy<IDistrbutionSystem>(); }
        }

        public IFinancialSystem FinancialSystem
        {
            get { return proxy.GetProxy<IFinancialSystem>(); }
        }

        public IOrganizationSystem OrganizationSystem
        {
            get { return proxy.GetProxy<IOrganizationSystem>(); }
        }

        public IProductManager ProductManager
        {
            get { return proxy.GetProxy<IProductManager>(); }
        }

        public ISecuritySystem SecuritySystem
        {
            get { return proxy.GetProxy<ISecuritySystem>(); }
        }

        public IStoreManager StoreManager
        {
            get { return proxy.GetProxy<IStoreManager>(); }
        }

        public ITradeSystem TradeSystem
        {
            get { return proxy.GetProxy<ITradeSystem>(); }
        }

        public IDataStorage DataStorage
        {
            get { return proxy.GetProxy<IDataStorage>(); }
        }

        public IFuturesManager FuturesMgr
        {
            get { return proxy.GetProxy<IFuturesManager>(); }
        }
    }
}